# Maintainer: Sergej Pupykin <arch+pub@sergej.pp.ru>
# Maintainer: Brian Bidulock <bidulock@openss7.org>
# Contributor: Ryan Corder <ryanc@greengrey.org>
# Contributor: Samuel Tardieu <sam@rfc1149.net>

pkgname=ckermit
pkgver=9.0.302
pkgrel=11
pkgdesc="Portable scriptable network and serial communication software"
arch=('loong64' 'x86_64')
license=('custom')
depends=(
  'glibc'
  'libxcrypt'
  'ncurses'
)
url="http://www.columbia.edu/kermit/ck90.html"
source=('http://www.columbia.edu/kermit/ftp/archives/cku302.tar.gz'
	'https://src.fedoraproject.org/rpms/ckermit/raw/rawhide/f/ckermit-9.0.302-fix_build_with_glibc_2_28_and_earlier.patch'
	'lockdir.patch')
sha512sums=('2cfc264e5262d29618fdf218fd3407fd9049b16110972cdddb03d114703b7a0ea13c4b0a354f50c2a9f70d4727732fe4d1920b5c656f969bc56c1eb9dc3c43fa'
            '80e1a3472b56d53f2d3e8926525e4964073dd9be9fb3e25d11cc3e3d1c96caaf3eb6bd84a9f0a2a0fb2cce980dd8e94a6b1be1afc72a89369c13f025cc3819ce'
            'daa67abcbd408486d7bdb790b7756d939ee0d8a99b36c09f781bebf3407a19e35c1367a19e1b98efa3c30d4b649a07b45ab4e154a4fea16aed8d59cfee754fc5')

prepare() {
  cd "$srcdir"
  chmod -R og-rwx ./*
  patch -p1 < lockdir.patch
  patch -p1 < ckermit-9.0.302-fix_build_with_glibc_2_28_and_earlier.patch
}

build() {
  cd "$srcdir"
  make linux \
        KFLAGS="-O0 -Wall -DOPENSSL_097 -Dsdata=s_data -DHAVE_OPENPTY -D'krb5_init_ets(__ctx)='" \
        K4LIB= \
        K4INC= \
        K5LIB=-lutil \
        K5INC=-I%{_includedir}/et \
        SSLLIB= \
        SSLINC=
  echo "#!/usr/bin/ckermit" > _tmp.ini
  cat ckermit.ini >> _tmp.ini
}

package() {
  cd "$srcdir"
  install -Dm0755 wermit "$pkgdir"/usr/bin/ckermit
  ln -s /usr/bin/ckermit "$pkgdir"/usr/bin/ckermit-sshsub
  install -Dm0644 ckuker.nr "$pkgdir"/usr//share/man/man1/ckermit.1
  install -Dm0644 COPYING.TXT "$pkgdir"/usr/share/licenses/$pkgname/License.txt
  install -Dm0755 _tmp.ini "$pkgdir"/usr/bin/ckermit.ini
}
